
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2707
 * @Author : WangRuoyu 
 * @Date : 2023/6/1 9:29
 */

#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    vector<int> find(string s, string word) {
        vector<int> res;
        for (int i = 0; i < s.size() - word.size() + 1; ++i) {
            bool flag = true;
            for (int j = 0; j < word.size(); ++j) {
                if (s[i + j] != word[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                res.push_back(i);
                break;
            }
        }
        return res;
    }

    int minExtraChar(string s, vector<string> &dictionary) {
        int res = 0;
        int cnt[s.size()];
        for (int &i: cnt) {
            i = 0;
        }
        for (string word: dictionary) {
            for (int k: find(s, word)) {
                for (int i = k; i < k + word.size(); ++i) {
                    cnt[i]++;
                }
            }
        }
        for (int i: cnt) {
            if (i == 0) res++;
        }
        return res;
    }
};

int main() {
    // TODO
    return 0;
}